<template>
    <view class="container">
        <view class="header-tabs">
            <view
                @tap="__e"
                :class="['tab-item', current == index ? 'active' : '']"
                :data-current="index"
                :data-event-opts="[['tap', [['currentChange', ['$event']]]]]"
                v-for="(item, index) in typeTextList"
                :key="index"
            >
                <text class="text">{{ '' + item + '' }}</text>

                <text class="tab-item-num" v-if="statusTotal[types[index]]">{{ statusTotal[types[index]] }}</text>
            </view>
        </view>
        <view class="swiper-wrapper">
            <swiper @change="__e" :current="current" :data-event-opts="[['change', [['currentChange2', ['$event']]]]]">
                <swiper-item v-for="(item, index) in $root.l1" :key="index">
                    <scroll-view @scrolltolower="__e" :data-event-opts="[['scrolltolower', [['scrolltolower', ['$event']]]]]" :scrollY="true">
                        <view class="order-list">
                            <order-item
                                @__l="
                                    __l($event, {
                                        eventOpts: [
                                            ['^check', [['checkItem', ['$0'], [[['dataList.' + index + '.list', 'uuid', order[$orig].uuid]]]]]],
                                            ['^action', [['actions']]]
                                        ]
                                    })
                                "
                                @action="
                                    __e($event, {
                                        eventOpts: [
                                            ['^check', [['checkItem', ['$0'], [[['dataList.' + index + '.list', 'uuid', order[$orig].uuid]]]]]],
                                            ['^action', [['actions']]]
                                        ]
                                    })
                                "
                                @check="
                                    __e($event, {
                                        eventOpts: [
                                            ['^check', [['checkItem', ['$0'], [[['dataList.' + index + '.list', 'uuid', order[$orig].uuid]]]]]],
                                            ['^action', [['actions']]]
                                        ]
                                    })
                                "
                                :data-event-opts="[
                                    ['^check', [['checkItem', ['$0'], [[['dataList.' + index + '.list', 'uuid', order[$orig].uuid]]]]]],
                                    ['^action', [['actions']]]
                                ]"
                                :isSelectMode="isSelectMode"
                                :isSelected="order.g0 > -1"
                                :order="order[$orig]"
                                :vueId="'77a7dac0-1-' + index + '-' + __i0__"
                                v-for="(order, __i0__) in item.l0"
                                :key="__i0__"
                            ></order-item>
                            <view class="load-more margin-v" v-if="item.g1 < dataList[index].total">加载中...</view>
                            <no-data @__l="__l" tips="无订单" :title="arrList[index]" :vueId="'77a7dac0-2-' + index" v-if="item.g2"></no-data>
                        </view>
                    </scroll-view>
                </swiper-item>
            </swiper>
        </view>
        <i-action-sheet
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            @change="
                __e($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            @visibleChange="
                __e($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^visibleChange', [['visibleChange']]],
                ['^change', [['cancelOrder']]]
            ]"
            :list="reasons"
            title="选择理由"
            :visible="visible"
            vueId="77a7dac0-3"
        ></i-action-sheet>
        <pay-card
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^success', [['successDeliver']]],
                        ['^cancel', [['e0']]]
                    ]
                })
            "
            @cancel="
                __e($event, {
                    eventOpts: [
                        ['^success', [['successDeliver']]],
                        ['^cancel', [['e0']]]
                    ]
                })
            "
            @success="
                __e($event, {
                    eventOpts: [
                        ['^success', [['successDeliver']]],
                        ['^cancel', [['e0']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^success', [['successDeliver']]],
                ['^cancel', [['e0']]]
            ]"
            :selectedId="selectedIds"
            vueId="77a7dac0-4"
            v-if="isShowPay"
        ></pay-card>
        <return-sale-popup-old
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^cancel', [['e1']]],
                        ['^refresh', [['refresh']]]
                    ]
                })
            "
            @cancel="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e1']]],
                        ['^refresh', [['refresh']]]
                    ]
                })
            "
            @refresh="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e1']]],
                        ['^refresh', [['refresh']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^cancel', [['e1']]],
                ['^refresh', [['refresh']]]
            ]"
            :uuid="currentUuid"
            vueId="77a7dac0-5"
            v-if="isShowReturnSalePopup"
        ></return-sale-popup-old>
    </view>
</template>

<script>
import noData from '@/components/NoData/NoData';
import returnSalePopupOld from '@/components/ReturnSalePopupOld/ReturnSalePopupOld';
import orderItem from '@/pages/orderList/components/OrderItem';
import iActionSheet from '@/components/ActionSheet/index';
import payCard from '@/pages/orderList/components/PayCard';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/orderList/index'],
    {
        '41ff': function (t, e, i) {
            'use strict';

            var n = i('591c');
            i.n(n).a;
        },
        '591c': function (t, e, i) {},
        '5f04': function (t, e, i) {
            'use strict';

            (function (t) {
                var n = i('4ea4');
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var a = n(i('2eee'));
                var s = n(i('c973'));
                var r = n(i('448a'));
                var o = n(i('82c0'));
                var c = {
                    components: {
                        OrderItem: function () {
                            Promise.all([i.e('common/vendor'), i.e('pages/orderList/components/OrderItem')])
                                .then(
                                    function () {
                                        return resolve(i('af3b'));
                                    }.bind(null, i)
                                )
                                .catch(i.oe);
                        },
                        IActionSheet: function () {
                            i.e('components/ActionSheet/index')
                                .then(
                                    function () {
                                        return resolve(i('fbfb'));
                                    }.bind(null, i)
                                )
                                .catch(i.oe);
                        },
                        PayCard: function () {
                            i.e('pages/orderList/components/PayCard')
                                .then(
                                    function () {
                                        return resolve(i('ea74'));
                                    }.bind(null, i)
                                )
                                .catch(i.oe);
                        }
                    },
                    data: function () {
                        return {
                            order: {},
                            reasons: [],
                            list: [],
                            visible: false,
                            dataList: [],
                            current: 0,
                            currentUuid: '6056e83ef3251',
                            types: ['pay_pending', 'deliver_pending', 'delivered', 'all'],
                            typeTextList: ['待付款', '待发货', '待收货', '全部'],
                            arrList: ['暂无待付款的订单', '暂无待发货的订单', '暂无待收货的订单', '暂无订单列表'],
                            isSelectMode: false,
                            selectedIds: [],
                            isShowPay: false,
                            isShowReturnSalePopup: false,
                            isRefresh: false,
                            statusTotal: {}
                        };
                    },
                    computed: {
                        orderConfig: function () {
                            return this.$store.getters.setting.order;
                        }
                    },
                    onLoad: function (e) {
                        var that = this;
                        this.current = this.types.indexOf(e.status || 'pending');
                        this.initData();
                        this.$api.emit('order.cancel_reason.list').then(function (t) {
                            that.reasons = t.data.list;
                        });
                        t.$on('postCommentSuccess', function (t) {
                            that.initData();
                            that.getOrderList();
                            console.log('postCommentSuccess');
                        });
                    },
                    onShow: function () {
                        this.refresh();
                    },
                    onUnload: function () {
                        t.$off('postCommentSuccess', function (t) {
                            console.log('移除postCommentSuccess 自定义事件');
                        });
                    },
                    methods: {
                        initTotalData: function () {
                            var that = this;
                            this.$http('/order-stat').then(function (e) {
                                that.statusTotal = e.data.info;
                            });
                        },
                        successDeliver: function () {
                            this.cancelSelect();
                            this.current = 2;
                            this.refresh();
                            this.isShowPay = false;
                            t.showModal({
                                title: '发货成功',
                                content: '已成功提交发货请求，请注意查收快递哦~'
                            });
                        },
                        cancelSelect: function () {
                            this.isSelectMode = false;
                            this.selectedIds = [];
                        },
                        selectOrSubmit: function () {
                            if (this.isSelectMode) {
                                if (0 == this.selectedIds.length) {
                                    t.showModal({
                                        title: '请选择盒子',
                                        content: '选择一个或多个盒子后才能提交发货哦~'
                                    });
                                    return false;
                                }
                                this.isShowPay = true;
                            } else {
                                this.isSelectMode = true;
                            }
                        },
                        checkItem: function (t) {
                            var e = this.selectedIds.indexOf(t.id);
                            if (e > -1) {
                                this.selectedIds.splice(e, 1);
                            } else {
                                this.selectedIds.push(t.id);
                            }
                        },
                        refresh: function () {
                            this.isRefresh = true;
                            this.cleanData();
                            this.getOrderList();
                            this.initTotalData();
                        },
                        scrolltolower: function () {
                            this.dataList[this.current].page++;
                            this.getOrderList();
                        },
                        initData: function () {
                            console.log(666);
                            var t = [];
                            this.types.forEach(function (e) {
                                t.push({
                                    list: [],
                                    type: e,
                                    page: 1,
                                    per_page: 50,
                                    total: 0,
                                    init: false,
                                    loading: false
                                });
                            });
                            this.dataList = t;
                        },
                        cleanData: function () {
                            this.dataList.forEach(function (t) {
                                t.page = 1;
                                t.init = false;
                            });
                        },
                        cancelOrder: function (e) {
                            var that = this;
                            this.visibleChange();
                            t.showLoading({
                                title: '加载中',
                                mask: true
                            });
                            this.$api
                                .emit('order.close', this.order.uuid)
                                .then(function (e) {
                                    var n = that.dataList[that.current];
                                    that.$api
                                        .emit('order.list', {
                                            status: n.type,
                                            page: 1,
                                            per_page: n.per_page
                                        })
                                        .then(function (e) {
                                            var n;
                                            t.hideLoading();
                                            that.initData();
                                            (n = that.dataList[that.current].list).push.apply(n, (0, r.default)(e.data.list));
                                            that.dataList[that.current].total = e.data.item_total;
                                            that.dataList[that.current].init = true;
                                            t.showToast({
                                                title: '已提交取消请求~',
                                                icon: 'none'
                                            });
                                        });
                                })
                                .catch(function (e) {
                                    t.hideLoading();
                                });
                        },
                        visibleChange: function () {
                            this.visible = !this.visible;
                        },
                        payOrder: function (e) {
                            var that = this;
                            return (0, s.default)(
                                a.default.mark(function n() {
                                    var s;
                                    return a.default.wrap(function (n) {
                                        for (;;) {
                                            switch ((n.prev = n.next)) {
                                                case 0:
                                                    t.showLoading({
                                                        mask: true
                                                    });
                                                    n.next = 3;
                                                    return that.$api.emit('order.pay_config', e, {
                                                        pay_type: 'wechat',
                                                        sub_type: 'miniapp'
                                                    });
                                                case 3:
                                                    s = n.sent;
                                                    t.hideLoading();
                                                    o.default.pay({
                                                        pay_config: s.data.pay_config,
                                                        success: function () {
                                                            t.showToast({
                                                                title: '支付成功',
                                                                icon: 'none'
                                                            });
                                                            that.refresh();
                                                        },
                                                        faild: function () {
                                                            t.showToast({
                                                                title: '支付失败',
                                                                icon: 'none'
                                                            });
                                                        }
                                                    });
                                                case 6:
                                                case 'end':
                                                    return n.stop();
                                            }
                                        }
                                    }, n);
                                })
                            )();
                        },
                        actions: function (e) {
                            var that = this;
                            switch (e.action) {
                                case '立即支付':
                                    this.payOrder(e.order.uuid);
                                    break;
                                case '取消订单':
                                    this.order = e.order;
                                    this.visibleChange();
                                    break;
                                case '返售':
                                    this.currentUuid = e.order.uuid;
                                    this.isShowReturnSalePopup = true;
                                    break;
                                case '删除订单':
                                    t.showModal({
                                        title: '提示',
                                        content: '确认要删除订单吗?',
                                        success: function (n) {
                                            if (n.confirm) {
                                                t.showLoading({
                                                    title: '加载中',
                                                    mask: true
                                                });
                                                that.$api.emit('order.destory', e.order.uuid).then(function (t) {
                                                    that.initData();
                                                    that.getOrderList();
                                                });
                                            }
                                        }
                                    });
                                    break;
                                case '提醒发货':
                                    break;
                                case '确认收货':
                                    t.showModal({
                                        title: '提示',
                                        content: '订单确认收货?',
                                        success: function (n) {
                                            if (n.confirm) {
                                                t.showLoading({
                                                    title: '加载中',
                                                    mask: true
                                                });
                                                that.$api.emit('order.complete', e.order.uuid).then(function (e) {
                                                    t.hideLoading();
                                                    that.refresh();
                                                });
                                            }
                                        }
                                    });
                                    break;
                                case '去评价':
                                    t.navigateTo({
                                        url: '/pages/writeComment/index?uuid=' + e.order.uuid
                                    });
                                    break;
                                case '核销码':
                                    t.navigateTo({
                                        url: '/pages/orderCode/index?uuid=' + e.order.uuid
                                    });
                            }
                        },
                        currentChange: function (t) {
                            var e = t.currentTarget.dataset.current;
                            if (e !== this.current) {
                                this.current = e;
                                var i = this.dataList[this.current];
                                console.log(i);
                                i.init || this.getOrderList();
                            }
                        },
                        currentChange2: function (t) {
                            var e = t.detail.current;
                            if (e !== this.current) {
                                this.current = e;
                                this.dataList[this.current].init || this.getOrderList();
                            }
                        },
                        getOrderList: function () {
                            var t = this.dataList[this.current];
                            t.loading ||
                                ((t.loading = true),
                                this.$api
                                    .emit('order.list', {
                                        status: t.type,
                                        page: t.page,
                                        per_page: t.per_page
                                    })
                                    .then(function (e) {
                                        var i;
                                        t.loading = false;
                                        if (1 === e.data.current_page) {
                                            t.list = e.data.list;
                                        } else {
                                            (i = t.list).push.apply(i, (0, r.default)(e.data.list));
                                        }
                                        t.total = e.data.item_total;
                                        t.init = true;
                                    }));
                        }
                    }
                };
                e.default = c;
            }.call(this, i('543d').default));
        },
        '67c1': function (t, e, i) {
            'use strict';

            i.r(e);
            var n = i('948f');
            var a = i('c51c');
            for (var s in a) {
                if (['default'].indexOf(s) < 0) {
                    (function (t) {
                        i.d(e, t, function () {
                            return a[t];
                        });
                    })(s);
                }
            }
            i('41ff');
            var r = i('f0c5');
            var o = Object(r.a)(a.default, n.b, n.c, false, null, null, null, false, n.a, void 0);
            e.default = o.exports;
        },
        '948f': function (t, e, i) {
            'use strict';

            i.d(e, 'b', function () {
                return a;
            });
            i.d(e, 'c', function () {
                return s;
            });
            i.d(e, 'a', function () {
                return n;
            });
            var n = {
                NoData: function () {
                    return i.e('components/NoData/NoData').then(i.bind(null, 'cafe'));
                },
                ReturnSalePopupOld: function () {
                    return i.e('components/ReturnSalePopupOld/ReturnSalePopupOld').then(i.bind(null, 'f428'));
                }
            };
            var a = function () {
                var that = this;
                var e =
                    (that.$createElement,
                    that._self._c,
                    that.__map(that.types, function (e, i) {
                        return {
                            $orig: that.__get_orig(e),
                            l0: that.__map(that.dataList[i].list, function (e, i) {
                                return {
                                    $orig: that.__get_orig(e),
                                    g0: that.selectedIds.indexOf(e.id)
                                };
                            }),
                            g1: that.dataList[i].list.length,
                            g2: that.dataList[i].init && !that.dataList[i].list.length
                        };
                    }));
                that._isMounted ||
                    ((that.e0 = function (e) {
                        that.isShowPay = false;
                    }),
                    (that.e1 = function (e) {
                        that.isShowReturnSalePopup = false;
                    }));
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            l1: e
                        }
                    }
                );
            };
            var s = [];
        },
        c51c: function (t, e, i) {
            'use strict';

            i.r(e);
            var n = i('5f04');
            var a = i.n(n);
            for (var s in n) {
                if (['default'].indexOf(s) < 0) {
                    (function (t) {
                        i.d(e, t, function () {
                            return n[t];
                        });
                    })(s);
                }
            }
            e.default = a.a;
        },
        ee45: function (t, e, i) {
            'use strict';

            (function (t, e) {
                var n = i('4ea4');
                i('18ba');
                n(i('66fd'));
                var a = n(i('67c1'));
                t.__webpack_require_UNI_MP_PLUGIN__ = i;
                e(a.default);
            }.call(this, i('bc2e').default, i('543d').createPage));
        }
    },
    [['ee45', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './index.css';
</style>
